home *** CD-ROM | disk | FTP | other *** search
- -- background: 3493 from stack: in
- -- bmap block id: 7817
- -- flags: 4000
- -- background id: 0
- -- name: Region Data
- ----- HyperTalk script -----
- on ConnectToVax
- global cl1_id, ConnectedToHost
- global connectMode,myHostName,myUserName,myPassword
-
- put "Connecting..." into field "Status"
- if connectMode <> "Simulation" then
- CL1init myHostName,myUserName,myPassword
- put the result into status
- if status is not empty then
- put "Cannot connect" into field "Status"
- return "cannot connect" --exit out of ConnectToVax
- end if
- end if
-
- put "Ready" into status
- put "Opening Database..." into field "Status"
- if connectMode <> "Simulation" then
- CL1send "op;"
- CL1exec
- put CL1status() into status
- end if
-
- put status = "Ready" into ConnectedToHost
- end ConnectToVax
-
- on DisconnectFromVax
- global cl1_id, ConnectedToHost, connectMode
- put "Disconnecting..." into field "Status"
- if connectMode <> "Simulation" then CL1end
- put "Disconnected" into field "Status"
- put false into ConnectedToHost
- end DisconnectFromVax
-
- on SendSalesRepData repNum, nuQuota, cardName
- global connectMode
- put "rep_nr,first_name,last_name,rep_office,title,salary,comm," & "quota,sales,supervisor,hire_date,yrs_service" into columnList
- put "staff" into table
-
- if connectMode <> "Simulation" then
- put 8 into quotaColumn
- put "where rep_nr =" && repNum into conditional
-
- ReplaceEntry columnList, table, conditional, quotaColumn, nuQuota, cardName
- else
- put "quota" into quotaColumn
- put "rep_nr" into keyField
- put repNum into keyValue
- S_ReplaceEntry columnList,table,keyfield,keyValue,quotaColumn, nuQuota,cardName
- end if
- end SendSalesRepData
-
- on SendRegionData regionNum, nuQuota
- global connectMode
- put "office_nr,city,region,manager,quota_ytd,sales_ytd" into columnList
- put "offices" into table
- put "All Regions" into cardName
-
- if connectMode <> "Simulation" then
- put 5 into quotaColumn
- put "where office_nr =" && regionNum into conditional
- ReplaceEntry columnList, table, conditional, quotaColumn, nuQuota, cardName
- else
- put "quota_ytd" into quotaColumn
- put "office_nr" into keyField
- put regionNum into keyValue
- S_ReplaceEntry columnList,table,keyfield,keyValue,quotaColumn, nuQuota,cardName
- end if
- end SendRegionData
-
- --on ReplaceEntry columnList, table, conditional, quotaColumn, nuQuota, cardName
- put the number of items in columnList into numColumns
-
- -- update the sales person’s data in the database
- put "update" && table && "set quota =" && nuQuota && conditional & ";" into query
-
- CL1send query
- CL1send "print $sqlcode;"
- CL1exec
- get last line of CL1getlist()
-
- if it is not empty then
- put "Unable to update data" into field "Status"
- wait 180
- exit to HyperCard
- end if
- end ReplaceEntry
-
-
- --debug: this is the old version of ReplaceEntry; i.e., delete the
- --old record then insert the updated version of the record.
-
- on ReplaceEntry columnList, table, conditional, quotaColumn, nuQuota, cardName
- put the number of items in columnList into numColumns
-
- -- Get the old row from the database
- put "select" && columnList && "from" && table && conditional & ";" into query
-
- CL1send query
- CL1send "printall;"
- CL1exec
- if CL1status() is not empty then
- put "Unable to receive data" into field "Status"
- wait 180
- exit to HyperCard
- end if
-
- get CL1getlist()
- put empty into dataReceived
- repeat with i = 1 to numColumns
- put stripSpaces (line i of it) into item i of dataReceived
- end repeat
-
- --put empty into last char of dataReceived
- put nuQuota into item quotaColumn of dataReceived
- repeat with i = 1 to the number of items in dataReceived
- put addQuotes (item i of dataReceived) into item i of dataReceived
- end repeat
-
- -- Delete the current record in the table
- put "delete from" && table && conditional & ";" into query
-
- if SendToVax (query, cardName) is not empty then
- put "Record deletion was unsuccessful"
- exit ReplaceEntry
- end if
-
- -- Insert a new record into the table
- put "insert into" && table && "(" & columnList & ") values " & dataReceived & ";" into query
- if SendToVax (query, cardName) is not empty then
- put "Record insertion was unsuccessful"
- end if
- end ReplaceEntry
-
- on S_ReplaceEntry columnList,table,keyField,keyValue,quotaColumn,nuQuota,cardName
- --simulated version of the ReplaceEntry handler
- global connectMode
- if connectMode <> "Simulation" then return "wrong mode"
-
- put the number of items in columnList into numColumns
-
- --get the record whose keyField contain keyValue in Host
- put card field keyField of card table into keyValueList
- get lineOffset(keyValue,keyValueList)
- if it = 0 then
- answer "Record replace fail: no match found."
- exit S_ReplaceEntry
- end if
-
- put it into myRecordNum
-
- --replace the value in the host database
- put nuQuota into line myRecordNum of card field quotaColumn of card table
-
- --replace the value in the local database
- --put nuQuota into line myRecordNum of card field quotaColumn of --card table
- end S_ReplaceEntry
-
- function SendToVax query, cardName
- global CL1_error
- CL1send query
- --CL1send "print $sqlcode;"
- CL1exec
- return CL1_error
- end SendToVax
-
- on PutDataInFields query, fieldsToFill, cardName
- global connectMode,CL1_error
- if cardName = empty then put the short name of this card into cardName
-
- repeat with i = 1 to the number of items in fieldsToFill
- put empty into field (item i of fieldsToFill) of card cardName
- end repeat
-
- put "Sending query..." into field "Status"
- put query into bkgnd field "Query" of card cardName
- CL1send query
- CL1send "printall;"
- CL1exec
-
- put "Receiving data..." into field "Status"
- put CL1getlist() into myData
- if CL1_error is not empty then
- put CL1_error into field "Status"
- return CL1_error --get out
- end if
- put 0 into rowCount
- put number of lines of myData into numValues
- put number of items of fieldsToFill into numFields
- repeat with i = 1 to numValues
- put stripSpaces (line i of myData) & "," after field (item (((i-1) mod numFields) + 1) of fieldsToFill) of card cardName
- end repeat
-
- --remove the extra comma’s
- repeat with i = 1 to numFields
- put empty into last char of field (item i of fieldsToFill) of card cardName
- end repeat
-
- put empty into field "Status"
- CalcPercents cardName
- end PutDataInFields
-
- on S_PutDataInFields s_query,tableName,recordList,fmFields,toFields,cardName
- --•• simulated version of PutDataInFields
- global connectMode
- if cardName = empty then put the short name of this card into cardName
-
- repeat with i = 1 to the number of items in toFields
- put empty into field (item i of toFields) of card cardName
- end repeat
-
- put "Sending query..." into field "Status"
- put s_query into bkgnd field "Query" of card cardName
-
- put "Receiving data..." into field "Status"
- put number of items of recordList into numRec
- repeat with j = 1 to numRec
- repeat with i = 1 to number of items in toFields
- get line (item j of recordList) of card field (item i of fmFields) of card tableName
-
- put stripSpaces(it) & "," after field (item i of toFields) of card cardName
- end repeat
- end repeat
- repeat with i = 1 to number of items in toFields
- put empty into last char of field (item i of toFields) of card cardName
- end repeat
-
- put empty into field "Status"
- CalcPercents cardName
- end S_PutDataInFields
-
- on CalcPercents cardName
- if cardName = empty then put the short name of this card into cardName
- put empty into field "Percent" of card cardName
- repeat with i = 1 to the number of items in field "Sales" of card cardName
- put item i of field "Sales" of card cardName into sales
- put item i of field "Quota" of card cardName into quota
- put formatPercent (sales / quota * 100) into percent
- put "," into last char of percent
- put percent after field "Percent" of card cardName
- end repeat
- put empty into last char of field "Percent" of card cardName
- end CalcPercents
-
- on openCard
- put empty into bkgnd field "Status"
- put empty into bkgnd field "Query"
- pass openCard
- end openCard
-
- on closeCard
- hide card field "Card Script"
- hide card field "Card Script Mask"
- set highlight of bkgnd btn "Script" to false
- pass closeCard
- end closeCard
-
-
-
-
- -- part 1 (field)
- -- low flags: 01
- -- high flags: 2000
- -- rect: left=97 top=37 right=60 bottom=487
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 0
- -- font id: 3
- -- text size: 12
- -- style flags: 256
- -- line height: 16
- -- part name:
-
-
- -- part 2 (field)
- -- low flags: 00
- -- high flags: 2002
- -- rect: left=97 top=63 right=85 bottom=489
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 0
- -- font id: 3
- -- text size: 10
- -- style flags: 0
- -- line height: 13
- -- part name: rep_nr
-
-
- -- part 3 (field)
- -- low flags: 00
- -- high flags: 2002
- -- rect: left=97 top=88 right=110 bottom=489
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 0
- -- font id: 3
- -- text size: 10
- -- style flags: 0
- -- line height: 13
- -- part name: quota
-
-
- -- part 4 (field)
- -- low flags: 00
- -- high flags: 2002
- -- rect: left=97 top=113 right=135 bottom=489
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 0
- -- font id: 3
- -- text size: 10
- -- style flags: 0
- -- line height: 13
- -- part name: sales
-
-
- -- part 10 (field)
- -- low flags: 00
- -- high flags: 2002
- -- rect: left=97 top=138 right=160 bottom=488
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 0
- -- font id: 3
- -- text size: 10
- -- style flags: 0
- -- line height: 13
- -- part name: office_nr
-
-
- -- part 11 (field)
- -- low flags: 00
- -- high flags: 2002
- -- rect: left=97 top=163 right=185 bottom=487
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 0
- -- font id: 3
- -- text size: 10
- -- style flags: 0
- -- line height: 13
- -- part name: city
-
-
- -- part 12 (field)
- -- low flags: 01
- -- high flags: 2002
- -- rect: left=97 top=188 right=210 bottom=486
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 0
- -- font id: 3
- -- text size: 10
- -- style flags: 0
- -- line height: 13
- -- part name: region
-
-
- -- part 6 (field)
- -- low flags: 01
- -- high flags: 2000
- -- rect: left=8 top=63 right=85 bottom=98
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 65535
- -- font id: 3
- -- text size: 10
- -- style flags: 256
- -- line height: 13
- -- part name:
-
-
- -- part 7 (field)
- -- low flags: 01
- -- high flags: 2000
- -- rect: left=17 top=88 right=110 bottom=98
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 65535
- -- font id: 3
- -- text size: 10
- -- style flags: 256
- -- line height: 13
- -- part name:
-
-
- -- part 8 (field)
- -- low flags: 01
- -- high flags: 2000
- -- rect: left=17 top=113 right=135 bottom=98
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 65535
- -- font id: 3
- -- text size: 10
- -- style flags: 256
- -- line height: 13
- -- part name:
-
-
- -- part 5 (field)
- -- low flags: 80
- -- high flags: 2002
- -- rect: left=97 top=213 right=235 bottom=486
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 0
- -- font id: 3
- -- text size: 10
- -- style flags: 0
- -- line height: 13
- -- part name: percent
-
-
- -- part 9 (field)
- -- low flags: 80
- -- high flags: 2000
- -- rect: left=17 top=138 right=160 bottom=98
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 65535
- -- font id: 3
- -- text size: 10
- -- style flags: 256
- -- line height: 13
- -- part name: percent label
-
-
- -- part 16 (field)
- -- low flags: 01
- -- high flags: 2000
- -- rect: left=7 top=138 right=160 bottom=98
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 65535
- -- font id: 3
- -- text size: 10
- -- style flags: 256
- -- line height: 13
- -- part name:
-
-
- -- part 17 (field)
- -- low flags: 01
- -- high flags: 2000
- -- rect: left=17 top=163 right=185 bottom=98
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 65535
- -- font id: 3
- -- text size: 10
- -- style flags: 256
- -- line height: 13
- -- part name:
-
-
- -- part 18 (field)
- -- low flags: 01
- -- high flags: 2000
- -- rect: left=17 top=188 right=210 bottom=98
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 65535
- -- font id: 3
- -- text size: 10
- -- style flags: 256
- -- line height: 13
- -- part name:
-
-
- -- part 22 (button)
- -- low flags: 00
- -- high flags: A002
- -- rect: left=97 top=301 right=324 bottom=190
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 1
- -- font id: 0
- -- text size: 12
- -- style flags: 0
- -- line height: 16
- -- part name: Connect
- ----- HyperTalk script -----
- on mouseUp
- ConnectToVax
- return the result
- end mouseUp
-
-
-
- -- part 24 (button)
- -- low flags: 00
- -- high flags: A002
- -- rect: left=295 top=301 right=324 bottom=388
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 1
- -- font id: 0
- -- text size: 12
- -- style flags: 0
- -- line height: 16
- -- part name: Disconnect
- ----- HyperTalk script -----
- on mouseUp
- DisconnectFromVax
- end mouseUp
-
-
-
- -- part 26 (field)
- -- low flags: 01
- -- high flags: 2000
- -- rect: left=17 top=275 right=299 bottom=98
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 65535
- -- font id: 3
- -- text size: 10
- -- style flags: 256
- -- line height: 13
- -- part name:
-
-
- -- part 28 (button)
- -- low flags: 80
- -- high flags: 8002
- -- rect: left=425 top=301 right=324 bottom=486
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 1
- -- font id: 0
- -- text size: 12
- -- style flags: 0
- -- line height: 16
- -- part name: %s
- ----- HyperTalk script -----
- on mouseUp
- CalcPercents ""
- end mouseUp
-
-
-
- -- part 29 (button)
- -- low flags: 00
- -- high flags: 0000
- -- rect: left=413 top=5 right=56 bottom=488
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 1
- -- font id: 0
- -- text size: 12
- -- style flags: 0
- -- line height: 16
- -- part name: Back to Map
- ----- HyperTalk script -----
- on mouseUp
- visual effect wipe left
- go to card "Map of Regions"
- end mouseUp
-
-
-
- -- part 30 (button)
- -- low flags: 00
- -- high flags: A002
- -- rect: left=196 top=301 right=324 bottom=289
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 1
- -- font id: 0
- -- text size: 12
- -- style flags: 0
- -- line height: 16
- -- part name: Get Data
- ----- HyperTalk script -----
- on mouseUp
- GetDataForCard
- end mouseUp
-
-
-
- -- part 31 (field)
- -- low flags: 00
- -- high flags: 2000
- -- rect: left=97 top=138 right=169 bottom=488
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 0
- -- font id: 3
- -- text size: 10
- -- style flags: 0
- -- line height: 13
- -- part name: last_name
-
-
- -- part 32 (field)
- -- low flags: 01
- -- high flags: 2000
- -- rect: left=17 top=213 right=235 bottom=98
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 65535
- -- font id: 3
- -- text size: 10
- -- style flags: 256
- -- line height: 13
- -- part name:
-
-
- -- part 33 (field)
- -- low flags: 01
- -- high flags: 2000
- -- rect: left=97 top=227 right=268 bottom=486
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 0
- -- font id: 3
- -- text size: 12
- -- style flags: 256
- -- line height: 16
- -- part name: query
-
-
- -- part 34 (field)
- -- low flags: 01
- -- high flags: 2000
- -- rect: left=17 top=229 right=251 bottom=98
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 65535
- -- font id: 3
- -- text size: 10
- -- style flags: 256
- -- line height: 13
- -- part name: query label
-
-
- -- part 36 (button)
- -- low flags: 00
- -- high flags: A002
- -- rect: left=394 top=301 right=324 bottom=486
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 1
- -- font id: 0
- -- text size: 12
- -- style flags: 0
- -- line height: 16
- -- part name: Script
- ----- HyperTalk script -----
- on mouseUp
- --•
- get the visible of card field "Card Script"
- if it is false then
- show card field "Card Script"
- show card field "Card Script Mask"
- --set highlight of me to true
- else
- hide card field "Card Script"
- hide card field "Card Script Mask"
- --set highlight of me to false
- end if
- end mouseUp
-
-
-
- -- part 37 (field)
- -- low flags: 01
- -- high flags: 2002
- -- rect: left=97 top=273 right=297 bottom=486
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 0
- -- font id: 3
- -- text size: 12
- -- style flags: 256
- -- line height: 16
- -- part name: Status
-
-
- -- part 44 (button)
- -- low flags: 80
- -- high flags: 8004
- -- rect: left=294 top=6 right=29 bottom=395
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 1
- -- font id: 0
- -- text size: 12
- -- style flags: 0
- -- line height: 16
- -- part name: CL/1
- ----- HyperTalk script -----
- on mouseUp
- exit mouseUp
-
- -- CL/1 & HyperCard :
- -- Initialize the globals needed by the CL/1 XCMD's and XFCN's. -----
- -- All stacks that use CL/1 MUST have these next statements. ------
- -- If you are using HyperCard 1.2 or above, you may omit all the
- -- initiailzations, and the declarations are necessary only if
- -- you want to reference a particular global.
- global cl1_id
- global cl1_error
- global cl1_status
- global cl1_status2
- global cl1_message
- put 0 into cl1_id
- put 0 into cl1_error
- put 0 into cl1_status
- put 0 into cl1_status2
- put "" into cl1_message
- --------------------------------------------------------------------
- -- the globals are used as follows :
- -- cl1_id : A variable used to store internal information from one
- -- invocation of the XCMD/XFCNs to another.
- -- cl1_error: Standard CL/1 error return string like "Error".
- -- The values of this, and the following globals are
- -- set only when an error is indicated by the command or
- -- function that was called. See the individual functions
- -- to determine how errors are indiacted.
- -- cl1status : If cl1err was "Error", then an error occured in the CL/1
- -- language executing on the host system. A DB2 compatible
- -- error number was returned from the host int cl1sts1.
- -- cl1status2: A secondary message number that goes with cl1sts1.
- -- cl1_message:An ascii message about the condition that caused the
- -- host to report an error.
- --------------------------------------------------------------------
- -- The functions :
- -- cl1init "hostname", "username", "password"
- -- This command will establish a connection with the host
- -- system. It must be called before any other CL/1
- -- XCMD/XFCN. It will modifiy the global cl1_id, but this
- -- should not be examined by the user. To test for errors,
- -- check if "the result" is not empty. If so, then no host
- -- connection has been established. Otherwise, you're in
- -- business. The first parameter to cl1init, hostname,
- -- is searched for in the CL/1 local configuration file.
- -- From it, the method of communication to the host is
- -- determined. If the username parameter is the empty
- -- string, "", then assumption is made that the connection
- -- has been previously logged into. Otherwise a valid
- -- user (account) name and password are required.
- --------------------------------------------------------------------
- -- cl1end
- -- This command terminates a conversation with the host
- -- system. It will modifiy the value of cl1_id, and after
- -- calling it, a cl1init is required before any other
- -- CL/1 XCMD/XFCNs may be issued. No error information
- -- is returned.
- --------------------------------------------------------------------
- -- cl1send "print 1;"
- -- This command sends the string to the host system. The
- -- parameter string should be a CL/1 statement. The host
- -- will store this and any other cl1send's until a cl1exec
- -- is issued. No error information is returned.
- --------------------------------------------------------------------
- -- cl1exec
- -- This command instructs the host to execute the
- -- statement(s) issued sofar via cl1write. No error
- -- information is returned.
- --------------------------------------------------------------------
- -- The next group of commands/functions are use to retrieve values
- -- from the host system.
- --------------------------------------------------------------------
- -- cl1status
- -- This function returns the current status of the host.
- -- The status could be one of the following, and can be
- -- checked after a cl1exec command :
- -- "Error" :
- -- The host encountered an error during execution of
- -- the CL/1 statements. The value of cl1_error...
- -- are set when this is returned. A developer may want
- -- to display cl1_message to get an idea of why the error
- -- occured.
- -- "Ready" :
- -- The host system is "ready", that is, it has no (more)
- -- data to send; it is waiting for more statements.
- -- This the value normally returned to indicate the end
- -- of the data stream produced by "your" CL/1 statements,
- -- and will, of course, be produced immediatly if the
- -- statements do not instruct the host system to send
- -- back data.
- -- "" :
- -- The host system has a value waiting to be received.
- -- A cl1getval call is appropriate.
- ---------------------------------------------------------------------
- -- cl1getval
- -- This function may be called to receive a value when there
- -- is one. It will return a "Ready" if there is no
- -- data ready, however, it is recommended that the cl1status
- -- function be called prior to cl1getval to determine if data
- -- is ready, and when it is, then cl1getval may be freely
- -- called without checking for errors.
- ---------------------------------------------------------------------
- -- cl1putval 3, "abc", 5, "def", -3, -2
- -- This command will place consective values sent from the
- -- host system into card field 3, then global abc, then
- -- card field 5, then global def. If an error should occur
- -- then "the result" will be not empty, and the value of
- -- globals cl1_error, cl1_status, cl1_status2, and
- -- cl1_message will contain information about the
- -- error condition. When using HyperCard versions before 1.2
- -- and putting values into variables, remember they must be
- -- "global", and it also seems necessary that they have
- -- been initialized (to 0 or something) in order for the
- -- xcmd to work. Also remember to put (double) quotes around
- -- the names of the global variables. Background fields may
- -- have values sent to them by using a negative number.
- -- This command can be used to fill effeciently and quickly
- -- an entire card, ie:
- -- cl1putval -1,-2,-3,-4,-5,-6
- -- without writing a hypertalk loop, and without needing
- -- to check the status of cl1 between each field that is set.
- ---------------------------------------------------------------------
- -- cl1getlist
- -- This function will return all the data values that the
- -- CL/1 statements instructed the host to return, in a
- -- carrige return separated string. Carrige return is used
- -- in case the data returned contains the comma character.
- -- Since this function does not have provisions for
- -- indicating successful completion, the global cl1err will
- -- be cleared on success, or set upon error. Of course,
- -- since this function is supposed to retrieve all the
- -- values from the data stream, it will not report "Ready"
- -- at end of the data stream.
- ---------------------------------------------------------------------
-
- global jjjj
- put 0 into jjjj
-
- put "Connecting..." into card field 2
-
- cl1init "nivax", "", ""
- -- host name, user name, password
-
- if the result is not empty then
- put "Cannot connect" into card field 2
- else
- put "Opening Database..." into card field 2
-
- cl1send "op;"
- cl1exec
- -- tell the host to execute the "op;" startup procedure
- -- which opens the demo database
-
- put "Query in progress..." into card field 2
-
- cl1send "select city, office_nr from offices;printall;"
- cl1exec
-
- -- the status of the query (success/failure) may be checked
- -- but it is not necessary, since the first attempt to get data
- -- will also return the status
- if cl1status() is not empty then
- put "Oops!" into card field 2
- end if
-
-
- put "Getting Results..." into card field 2
-
- cl1putval 3, 4, 5, 6, 7, "jjjj"
- -- Tell the host to retrieve some values, and
- -- put them into card fields 3-7 and global jjjj.
- -- To retrieve data into backgound fields, specify negative of
- -- background field number.
- -- Errors can be checked by testing "the result" at this point
- -- for example :
- -- if the result is not empty then
- -- error information is in the globals :
- ---- cl1_error, cl1_status, cl1_message.
- -- end if
- put the result into card field 9
-
- put cl1getlist() into card field 8
- -- put the rest of the values, cr separated into one string
- -- and put that into card field 8
- put cl1_error into card field 10
-
- -- For developers of stacks using CL/1, you can use the cl1msg
- -- field to retrieve error messages from the host, which will
- -- help you debug your CL/1 and SQL type of statements.
- -- now let's get a CL/1 error
- -- note: the correct way to get CL/1 to print hello would be
- -- cl1send "print 'hello';"
- cl1send "print hello;"
- cl1exec
- cl1putval "into asdf"
- if the result is not empty then
- put cl1_message into card field 11
- end if
-
- cl1end
- -- disconnect from host
-
- put "Disconnected" into card field 2
- end if
- end mouseUp
-
-
-